home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / m68k / fbug68k.arc / MD.C < prev    next >
C/C++ Source or Header  |  1989-08-17  |  3KB  |  121 lines

  1. #include"userdef.h"
  2.  
  3. /* ************************************************* */
  4. /* 
  5. md [<size>] <range>
  6. Memory Display -> This command displays memory on the screen in <size>
  7. large units.
  8.  
  9. A check is first made for to many arguments on the command line. If not then
  10. a check is made for size option. Next the range is determined in two parts,
  11. the starting address and the count of "size" large units to get.
  12. Finally the data is displayed, with a check made to see if the screen is 
  13. overflowing. If it is overflowing, then the HITKEYMSG message is printed
  14. out and output is suspended until any key is hit.
  15. */
  16. /* ************************************************* */
  17.  
  18. mdcmd(argc,argv)
  19. int argc;
  20. char *argv;
  21. {
  22. extern int error;
  23. register int start,count, addr, data, size, num;
  24. register int j;
  25. char ch;
  26.  
  27.     if (argc > 3)
  28.         print(ERR01);
  29.     else
  30.         {
  31.         striparg(argv);
  32.         if(argv[0] == '-' && 
  33.             (argv[1] == 'd' || argv[1] == 'D') &&
  34.             (argv[2] == 'i' || argv[2] == 'I'))
  35.             {
  36.             striparg(argv);
  37.             start = getnum(argv,ERR02,DEFAULTSCALE);
  38.             if(error)
  39.                 return(0);
  40.     
  41.             for (j=0;;j++)
  42.             {
  43.                 size = disasm(start);
  44.                 print("\n");
  45.                 start = start + size;
  46.                 if(check())
  47.                     break;
  48.                 j = j + size/6;
  49.                 if (j >= MAXSCREEN)
  50.                 {
  51.                     j = 0;
  52.                     print("\nType 's' to Halt (any other key to continue...)\n");
  53.                     ch = getch(TERMINAL,FALSE);
  54.                     if(ch == 's' || ch == 'S')    
  55.                         return;
  56.                 }
  57.             }
  58.             }
  59.         else
  60.             {
  61.             size = getsize(argv,ERR04);
  62.             if (size < 0)
  63.                 return(0);
  64.             start = getnum(argv,ERR02,DEFAULTSCALE);
  65.             if (error)
  66.                 return(0);
  67.             count = getcount(argv,size,start,NOERR);
  68.             if (count < 0)
  69.                 count = DEFCOUNT;
  70.             addr = 0;
  71.             num = 0;
  72.             while (count >0)
  73.             {
  74.                 if (addr == 0)
  75.                     print("%c%8x:  ",HEXDEL,start);
  76.                 switch (size)
  77.                 {
  78.                     case 1:
  79.                         data = get8(start);
  80.                         print("%c%2X  ",HEXDEL,data);
  81.                         start = start + 1;
  82.                         count--;
  83.                         break;
  84.                     case 2:
  85.                         data = get16(start);
  86.                         print("%c%4X  ",HEXDEL,data);
  87.                         start = start + 2;
  88.                         count--;
  89.                         break;
  90.                     case 4:
  91.                         data = get32(start);
  92.                         print("%c%8X  ",HEXDEL,data);
  93.                         start = start + 4;
  94.                         count--;
  95.                         break;
  96.                     default:
  97.                         print(ERR01);
  98.                         return(0);    
  99.                 }
  100.                 if (++addr == MEMLINEDIS)
  101.                 {
  102.                     print("\n");
  103.                     addr = 0;
  104.                     if (check())
  105.                     {
  106.                         print("\n");
  107.                         return(0);
  108.                     }
  109.                     if (num++ == MAXSCREEN)
  110.                     {
  111.                         num = 0;
  112.                         print(HITKEYMSG);
  113.                         getch(TERMINAL,FALSE);
  114.                     }
  115.                 }
  116.             }/* end while */
  117.             print("\n");
  118.         }/* end else */
  119.     }/* end else */
  120. }/* end function */
  121.